function debounce(fn: (...args: any[]) => any, delay: number = 200) {
    let timer: null | number = null
    return function (this: any) {
        // 设置了定时器就清空这个定时器，没有就去设置定时器
        timer && clearTimeout(timer)
        // 获取debounce执行作用域的this
        let _this = this
        // 获取参数
        let args = [...arguments]

        timer = window.setTimeout(function () {
            fn.apply(_this, args)
        }, delay)
    }
}